#pragma once

#include <QQuickItem>

class QmlGraphicsView;
class QmlGraphicsItem : public QQuickItem
{
    Q_OBJECT
public:
    explicit QmlGraphicsItem(QQuickItem* parent = nullptr);
    virtual ~QmlGraphicsItem() override;
    Q_DISABLE_COPY(QmlGraphicsItem)

public:
    Q_PROPERTY(QmlGraphicsView* view READ getView WRITE setView NOTIFY viewChanged FINAL)
    Q_PROPERTY(QColor background READ getBackground WRITE setBackground NOTIFY backgroundChanged FINAL)
    Q_PROPERTY(bool selected READ getSelected WRITE setSelected NOTIFY selectedChanged FINAL)

    inline QmlGraphicsView* getView()
    {
        return m_viewItem;
    }

    void setView(QmlGraphicsView* item);

    inline bool getSelected() const
    {
        return m_selected;
    }

    void setSelected(bool selected);

    QColor getBackground() const
    {
        return m_background;
    }

    void setBackground(QColor background);

signals:
    void viewChanged();
    void selectedChanged();
    void backgroundChanged();

private:
    QmlGraphicsView* m_viewItem = nullptr;
    bool m_selected = false;
    QColor m_background = QColor(0, 0, 0, 0);
};

QML_DECLARE_TYPE(QmlGraphicsItem)
